package sky.cin.framework.network.nio;


import sky.cin.framework.network.dto.HttpServletRequest;
import sky.cin.framework.network.http.Response;
import sky.cin.framework.nio.NioUtils;

import java.io.IOException;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;

public class ServerUtils {
    public static Response doInvoke(SocketChannel socketChannel, HttpServletRequest request, Selector selector) {
        String str = NioUtils.doInvoke(socketChannel, request.toString(), selector);
        return new Response(str);
    }

    public static void sendRequest(SocketChannel socketChannel, HttpServletRequest request) throws IOException {
        NioUtils.write(socketChannel, request.toString());
    }
}
